var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../utils/util.js")), a = getApp(), e = require("../../../mycomponent/yz_pay/yz_pay");

Page({
    behaviors: [ e ],
    data: {
        language: "",
        id: "",
        showPopup: !1,
        ios_virtual_pay: !1
    },
    onLoad: function(t) {
        this.setData({
            id: t.article_id
        }), console.log(t.id), this.getData();
        try {
            var a = wx.getStorageSync("ios_virtual_pay");
            a && this.setData({
                ios_virtual_pay: a
            });
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), a = "";
        return t && (a = t), {
            path: "/packageA/member/article/articleContent/articleContent?article_id=" + this.data.id + "&mid=" + a,
            title: this.data.dataInfo && this.data.dataInfo.title || "",
            imageUrl: this.data.dataInfo && this.data.dataInfo.thumb ? this.data.dataInfo.thumb : ""
        };
    },
    showzhifu: function() {
        if (this.data.ios_virtual_pay) return wx.showModal({
            title: "提示",
            content: "十分抱歉，由于相关规定，你暂时无法在这里充值！",
            confirmText: "知道了",
            showCancel: !1,
            success: function(t) {
                t.confirm && console.log(t.confirm);
            }
        }), !1;
        this.getPayData(), this.setData({
            showPopup: !0
        });
    },
    tapPay: function(t) {
        var e = this, i = t.currentTarget.dataset.value, o = this.data.dataInfo.money, n = t.currentTarget.dataset.name;
        console.log(i, o, n);
        var s = {
            pay_id: i,
            money: o,
            pay_name: n,
            id: this.data.id,
            art: "pay"
        }, r = a.getNetAddresss("plugin.article-pay.api.index.orderPay");
        r += "&client_type=2", a._getNetWork({
            url: r,
            data: s,
            success: function(t) {
                var a = t.data;
                1 == a.result ? e.rechargePay(i, a, a.data.ordersn) : wx.showToast({
                    title: a.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onClose: function() {
        this.setData({
            showPopup: !1
        });
    },
    offshow: function() {
        this.setData({
            showPopup: !1
        });
    },
    getData: function() {
        var e = this, i = a.getNetAddresss("plugin.article-pay.api.index.articlePayData");
        i += "&id=" + this.data.id, i += "&art=detail", a._getNetWork({
            url: i,
            success: function(a) {
                var i = a.data;
                console.log(i);
                var o = t.default.formatTimeTwo(i.data.payDetail.virtual_created_at, "Y,M,D").replace(/,/g, ".");
                e.setData({
                    dataInfo: i.data.payDetail,
                    is_time: o
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getPayData: function() {
        var t = this, e = a.getNetAddresss("plugin.article-pay.api.index.getPayType");
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                t.setData({
                    buttons: e.data.buttons
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});